﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Vds2465Telegrams
{
	[TestClass]
	public class UserData_03_StatusChangeConfirm_Test
	{
		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test01_Equals_NoReportType()
		{
			UserData_03_StatusChangeConfirm userData = new UserData_03_StatusChangeConfirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, null);

			{
				// completely different type - NOT equal
				object dummyObject = new object();
				Assert.IsFalse(userData.Equals(dummyObject));
			}

			{
				// different derived type
				UserData userData2Compare = new UserData_01_Priority(0x77);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same object - equal
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, userData.Address, userData.AddressAddOn, userData.AddressExtension, userData.TheReportType);
				Assert.IsTrue(userData.Equals(userData2Compare));
			}

			{
				// different Device value - NOT equal
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					((byte)(userData.Device + 1), userData.Address, userData.AddressAddOn, userData.AddressExtension, userData.TheReportType);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// different Address value - NOT equal
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, (byte)(userData.Address + 10), userData.AddressAddOn, userData.AddressExtension, userData.TheReportType);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// different AddressAddOn value - NOT equal
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, userData.Address, (byte)(userData.AddressAddOn + 5), userData.AddressExtension, userData.TheReportType);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// different AddressExtension value - NOT equal
				eAddressExtension_1 addressExtension = eAddressExtension_1.Output;
				if (userData.AddressExtension == eAddressExtension_1.Output)
				{
					addressExtension = eAddressExtension_1.Input;
				}
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, userData.Address, userData.AddressAddOn, addressExtension, userData.TheReportType);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test02_Equals_ReportType()
		{
			ReportType_Fire reportTypeFire = new ReportType_Fire(true, eReportSubType_Fire.ExtinguishingSystem);
			UserData_03_StatusChangeConfirm userData = new UserData_03_StatusChangeConfirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportTypeFire);

			{
				// same object - equal
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, userData.Address, userData.AddressAddOn, userData.AddressExtension, userData.TheReportType);
				Assert.IsTrue(userData.Equals(userData2Compare));
			}

			{
				// same properties but no ReportType
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, userData.Address, userData.AddressAddOn, userData.AddressExtension, null);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same properties but different ReportType
				ReportType_General reportTypeGeneral = new ReportType_General(false, eReportSubType_General.Revision);
				UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
					(userData.Device, userData.Address, userData.AddressAddOn, userData.AddressExtension, reportTypeGeneral);
				Assert.IsFalse(userData.Equals(userData2Compare));
			}

			{
				// same properties with same ReportType Sub type but different on off flag
				ReportType_Base reportTypeRet = userData.TheReportType;
				ReportType_Fire reportTypeRetFire = reportTypeRet as ReportType_Fire;
				if (reportTypeFire != null)
				{
					ReportType_Fire reportTypeFire2Compare = new ReportType_Fire(!reportTypeRetFire.OnOffFlag, reportTypeRetFire.ReportSubType);

					UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
						(userData.Device, userData.Address, userData.AddressAddOn, userData.AddressExtension, reportTypeFire2Compare);
					Assert.IsFalse(userData.Equals(userData2Compare));
				}
			}

			{
				// same properties with same ReportType Sub type but different ...
				ReportType_Base reportTypeRet = userData.TheReportType;
				ReportType_Fire reportTypeRetFire = reportTypeRet as ReportType_Fire;
				if (reportTypeFire != null)
				{
					eReportSubType_Fire eReportSubTypeFire = eReportSubType_Fire.General;
					if (reportTypeRetFire.ReportSubType == eReportSubType_Fire.General)
					{
						eReportSubTypeFire = eReportSubType_Fire.Automatic;
					}
					ReportType_Fire reportTypeFire2Compare = new ReportType_Fire(reportTypeRetFire.OnOffFlag, eReportSubTypeFire);

					UserData_03_StatusChangeConfirm userData2Compare = new UserData_03_StatusChangeConfirm
						(userData.Device, userData.Address, userData.AddressAddOn, userData.AddressExtension, reportTypeFire2Compare);
					Assert.IsFalse(userData.Equals(userData2Compare));
				}
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test03_GetHashCode()
		{
			{
				UserData_03_StatusChangeConfirm userData = new UserData_03_StatusChangeConfirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, null);
				int hashCode = userData.GetHashCode();
			}

			{
				ReportType_Fire reportTypeFire = new ReportType_Fire(true, eReportSubType_Fire.ExtinguishingSystem);
				UserData_03_StatusChangeConfirm userData = new UserData_03_StatusChangeConfirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportTypeFire);
				int hashCode = userData.GetHashCode();
			}
		}

		[TestMethod]
		[Owner("Frank Eppink")]
		public void Test04_ToString()
		{
			{
				UserData_03_StatusChangeConfirm userData = new UserData_03_StatusChangeConfirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, null);
				string stringResult = userData.ToString();
				Assert.IsNotNull(stringResult);
			}

			{
				ReportType_General reportTypeGeneral = new ReportType_General(false, eReportSubType_General.Revision);
				UserData_03_StatusChangeConfirm userData = new UserData_03_StatusChangeConfirm(0x01, 0x02, 0x03, eAddressExtension_1.Input, reportTypeGeneral);
				string stringResult = userData.ToString();
				Assert.IsNotNull(stringResult);
			}
		}
	}
}
